package com.jltx.storage.coroutinesdownloader

import android.content.Context
import okhttp3.OkHttpClient

/**
 * @author jltxseo
 *         Created by junlintianxia on 2020/04/15.
 */
class StorageDownloader {
    companion object {
        @JvmStatic
        fun init(context: Context) {
            Downloader.init(context)
        }

        /**
         * 使用前必须初始化
         *
         * @param okHttpClient
         */
        @JvmStatic
        fun initHttpClient(okHttpClient: OkHttpClient?) {
            Downloader.initHttpClient(okHttpClient)
        }

        /**
         * 下载单个文件
         *
         * @param tag          标记下载任务的tag
         * @param url          要下载的文件的url链接
         * @param localPath    要下载的文件输出本地全路径
         * @param fileCallback 回调监听器
         */
        @JvmStatic
        fun download(
            tag: Any?,
            url: String?,
            localPath: String?,
            fileCallback: FileCallback<RequestResult>?
        ) {
            Downloader.download(tag, url, localPath, fileCallback)
        }
    }
}